import { time } from '@/utils/performance';
import { bubbleSort as b } from '../bubbleSort'
import { selectionSort as s } from '../selectionSort'
import { heapSort as h } from '../heapSort'
import { insertionSort as i } from '../insertionSort'
import { mergeSort as m } from '../mergeSort'
import { quickSort as q } from '../quickSort'
import { shellSort as sh } from '../shellSort'
import { countSort as c } from '../countSort'
import { isSorted, randomArr } from '../util'

export const test = () => {
    // const arr = randomArr(0, 10000000, 9000000),
    const arr = randomArr(0, 1000000, 900000),
        arr2 = arr.slice(),
        arr3 = arr.slice(),
        arr4 = arr.slice(),
        arr5 = arr.slice(),
        arr6 = arr.slice(),
        arr7 = arr.slice(),
        arr8 = arr.slice();



    // time("bubbleSort", () => {
    //     b(arr)
    // })
    // p(arr)

    // time("selectSort", () => {
    //     s(arr2)
    // })
    // p(arr2)

    time('heapSort', () => {
        h(arr3)
    })
    p(arr3)

    // time("insertionSort", () => {
    //     i(arr4)
    // })
    // p(arr4)

    time('mergeSort', () => {
        m(arr5)
    })
    p(arr5)

    time('quickSort', () => {
        q(arr6)
    })
    p(arr6)

    // time('shellSort', () => {
    //     sh(arr7)
    // })
    // p(arr7)

    time('countSort', () => {
        c(arr8)
    })
    p(arr8)
    console.log(arr8)
}

const p = (arr: number[]) => {
    console.log(isSorted(arr))
}